{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "id": "ZejZZonxwCMH",
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MONAI version: 1.2.0\n",
      "Numpy version: 1.24.3\n",
      "Pytorch version: 2.0.0+cu118\n",
      "MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n",
      "MONAI rev id: c33f1ba588ee00229a309000e888f9817b4f1934\n",
      "MONAI __file__: /home/yawei/anaconda3/lib/python3.10/site-packages/monai/__init__.py\n",
      "\n",
      "Optional dependencies:\n",
      "Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.\n",
      "ITK version: 5.3.0\n",
      "Nibabel version: 5.1.0\n",
      "scikit-image version: 0.19.3\n",
      "Pillow version: 9.4.0\n",
      "Tensorboard version: 2.15.0a20230914\n",
      "gdown version: NOT INSTALLED or UNKNOWN VERSION.\n",
      "TorchVision version: 0.15.1+cu118\n",
      "tqdm version: 4.64.1\n",
      "lmdb version: NOT INSTALLED or UNKNOWN VERSION.\n",
      "psutil version: 5.9.0\n",
      "pandas version: 1.5.3\n",
      "einops version: 0.7.0\n",
      "transformers version: 4.36.2\n",
      "mlflow version: NOT INSTALLED or UNKNOWN VERSION.\n",
      "pynrrd version: 1.0.0\n",
      "\n",
      "For details about installing the optional dependencies, please visit:\n",
      "    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from monai.utils import first, set_determinism\n",
    "from monai.transforms import (\n",
    "    AsDiscrete,\n",
    "    AsDiscreted,\n",
    "    EnsureChannelFirstd,\n",
    "    Compose,\n",
    "    CropForegroundd,\n",
    "    LoadImaged,\n",
    "    Orientationd,\n",
    "    RandCropByPosNegLabeld,\n",
    "    ScaleIntensityRanged,\n",
    "    Spacingd,\n",
    "    Invertd,\n",
    "    SpatialPadd,\n",
    ")\n",
    "from monai.handlers.utils import from_engine\n",
    "# https://docs.monai.io/en/stable/networks.html#nets\n",
    "from monai.networks.nets import UNet,AttentionUnet, DynUNet, SegResNet, VNet, SegResNetVAE, UNETR\n",
    "from monai.networks.layers import Norm\n",
    "from monai.metrics import DiceMetric\n",
    "from monai.losses import DiceLoss\n",
    "from monai.inferers import sliding_window_inference\n",
    "from monai.data import CacheDataset, DataLoader, Dataset, decollate_batch\n",
    "from monai.config import print_config\n",
    "from monai.apps import download_and_extract\n",
    "import aim\n",
    "from aim.pytorch import track_gradients_dists, track_params_dists\n",
    "import torch\n",
    "import matplotlib.pyplot as plt\n",
    "import tempfile\n",
    "import shutil\n",
    "import os\n",
    "import glob\n",
    "\n",
    "print_config()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "w3EPRPqBwCMN"
   },
   "source": [
    "## Set MSD dataset path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "id": "lVZr7-kBwCMO"
   },
   "outputs": [],
   "source": [
    "root_dir = '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data'\n",
    "data_dir = '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/'\n",
    "train_images = sorted(glob.glob(os.path.join(data_dir, \"imagesTr\", \"*.nii.gz\")))\n",
    "# train_labels = sorted(glob.glob(os.path.join(data_dir, \"labelsTr\", \"*.nii.gz\")))\n",
    "train_labels = [i.replace('_0000','').replace('imagesTr','labelsTr') for i in train_images]\n",
    "\n",
    "data_dicts = [{\"image\": image_name, \"label\": label_name} for image_name, label_name in zip(train_images, train_labels)]\n",
    "train_num = int(len(data_dicts)*0.7)\n",
    "train_files, val_files = data_dicts[:-train_num], data_dicts[-train_num:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_001_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_001.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_003_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_003.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_004_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_004.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_006_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_006.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_007_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_007.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_008_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_008.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_011_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_011.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_014_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_014.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_015_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_015.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_017_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_017.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_019_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_019.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_020_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_020.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_023_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_023.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_024_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_024.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_025_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_025.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_026_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_026.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_033_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_033.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_034_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_034.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_035_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_035.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_036_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_036.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_037_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_037.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_038_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_038.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_039_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_039.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_040_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_040.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_041_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_041.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_042_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_042.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_044_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_044.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_045_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_045.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_046_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_046.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_048_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_048.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_049_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_049.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_050_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_050.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_051_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_051.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_052_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_052.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_053_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_053.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_056_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_056.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_057_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_057.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_058_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_058.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_060_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_060.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_064_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_064.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_065_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_065.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_067_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_067.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_068_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_068.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_070_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_070.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_074_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_074.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_075_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_075.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_077_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_077.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_083_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_083.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_084_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_084.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_087_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_087.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_088_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_088.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_089_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_089.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_090_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_090.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_091_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_091.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_092_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_092.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_093_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_093.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_094_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_094.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_095_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_095.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_096_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_096.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_097_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_097.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_098_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_098.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_099_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_099.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_101_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_101.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_102_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_102.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_104_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_104.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_105_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_105.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_106_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_106.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_107_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_107.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_108_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_108.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_109_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_109.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_114_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_114.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_123_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_123.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_124_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_124.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_125_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_125.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_126_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_126.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_127_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_127.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_130_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_130.nii.gz'},\n",
       " {'image': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_132_0000.nii.gz',\n",
       "  'label': '/mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/labelsTr/hippocampus_132.nii.gz'}]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(35, 51, 35) (35, 51, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_001_0000.nii.gz\n",
      "(34, 52, 35) (34, 52, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_003_0000.nii.gz\n",
      "(36, 52, 38) (36, 52, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_004_0000.nii.gz\n",
      "(35, 52, 34) (35, 52, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_006_0000.nii.gz\n",
      "(34, 47, 40) (34, 47, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_007_0000.nii.gz\n",
      "(36, 48, 40) (36, 48, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_008_0000.nii.gz\n",
      "(36, 50, 31) (36, 50, 31) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_011_0000.nii.gz\n",
      "(39, 50, 40) (39, 50, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_014_0000.nii.gz\n",
      "(42, 51, 28) (42, 51, 28) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_015_0000.nii.gz\n",
      "(35, 48, 32) (35, 48, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_017_0000.nii.gz\n",
      "(36, 47, 41) (36, 47, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_019_0000.nii.gz\n",
      "(36, 46, 43) (36, 46, 43) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_020_0000.nii.gz\n",
      "(35, 51, 35) (35, 51, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_023_0000.nii.gz\n",
      "(38, 52, 33) (38, 52, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_024_0000.nii.gz\n",
      "(35, 48, 35) (35, 48, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_025_0000.nii.gz\n",
      "(36, 50, 36) (36, 50, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_026_0000.nii.gz\n",
      "(33, 48, 38) (33, 48, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_033_0000.nii.gz\n",
      "(36, 49, 40) (36, 49, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_034_0000.nii.gz\n",
      "(35, 47, 37) (35, 47, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_035_0000.nii.gz\n",
      "(36, 47, 39) (36, 47, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_036_0000.nii.gz\n",
      "(34, 51, 32) (34, 51, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_037_0000.nii.gz\n",
      "(37, 51, 35) (37, 51, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_038_0000.nii.gz\n",
      "(34, 53, 34) (34, 53, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_039_0000.nii.gz\n",
      "(36, 52, 37) (36, 52, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_040_0000.nii.gz\n",
      "(36, 51, 34) (36, 51, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_041_0000.nii.gz\n",
      "(37, 52, 34) (37, 52, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_042_0000.nii.gz\n",
      "(38, 48, 33) (38, 48, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_044_0000.nii.gz\n",
      "(36, 48, 37) (36, 48, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_045_0000.nii.gz\n",
      "(36, 49, 38) (36, 49, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_046_0000.nii.gz\n",
      "(38, 52, 29) (38, 52, 29) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_048_0000.nii.gz\n",
      "(35, 51, 36) (35, 51, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_049_0000.nii.gz\n",
      "(38, 49, 38) (38, 49, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_050_0000.nii.gz\n",
      "(33, 54, 39) (33, 54, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_051_0000.nii.gz\n",
      "(34, 52, 40) (34, 52, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_052_0000.nii.gz\n",
      "(37, 51, 35) (37, 51, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_053_0000.nii.gz\n",
      "(41, 47, 42) (41, 47, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_056_0000.nii.gz\n",
      "(35, 51, 34) (35, 51, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_057_0000.nii.gz\n",
      "(34, 53, 36) (34, 53, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_058_0000.nii.gz\n",
      "(39, 52, 31) (39, 52, 31) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_060_0000.nii.gz\n",
      "(35, 53, 35) (35, 53, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_064_0000.nii.gz\n",
      "(39, 52, 37) (39, 52, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_065_0000.nii.gz\n",
      "(36, 42, 41) (36, 42, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_067_0000.nii.gz\n",
      "(36, 40, 43) (36, 40, 43) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_068_0000.nii.gz\n",
      "(37, 50, 38) (37, 50, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_070_0000.nii.gz\n",
      "(37, 47, 42) (37, 47, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_074_0000.nii.gz\n",
      "(32, 47, 41) (32, 47, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_075_0000.nii.gz\n",
      "(35, 47, 45) (35, 47, 45) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_077_0000.nii.gz\n",
      "(33, 52, 37) (33, 52, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_083_0000.nii.gz\n",
      "(34, 52, 37) (34, 52, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_084_0000.nii.gz\n",
      "(35, 55, 32) (35, 55, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_087_0000.nii.gz\n",
      "(40, 52, 35) (40, 52, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_088_0000.nii.gz\n",
      "(34, 51, 38) (34, 51, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_089_0000.nii.gz\n",
      "(37, 50, 40) (37, 50, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_090_0000.nii.gz\n",
      "(36, 51, 29) (36, 51, 29) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_091_0000.nii.gz\n",
      "(38, 49, 28) (38, 49, 28) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_092_0000.nii.gz\n",
      "(34, 53, 37) (34, 53, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_093_0000.nii.gz\n",
      "(38, 50, 38) (38, 50, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_094_0000.nii.gz\n",
      "(34, 49, 39) (34, 49, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_095_0000.nii.gz\n",
      "(34, 47, 39) (34, 47, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_096_0000.nii.gz\n",
      "(37, 48, 34) (37, 48, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_097_0000.nii.gz\n",
      "(37, 48, 34) (37, 48, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_098_0000.nii.gz\n",
      "(33, 52, 27) (33, 52, 27) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_099_0000.nii.gz\n",
      "(36, 52, 32) (36, 52, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_101_0000.nii.gz\n",
      "(36, 55, 32) (36, 55, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_102_0000.nii.gz\n",
      "(35, 53, 39) (35, 53, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_104_0000.nii.gz\n",
      "(33, 47, 37) (33, 47, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_105_0000.nii.gz\n",
      "(34, 46, 38) (34, 46, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_106_0000.nii.gz\n",
      "(35, 55, 34) (35, 55, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_107_0000.nii.gz\n",
      "(36, 53, 37) (36, 53, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_108_0000.nii.gz\n",
      "(36, 49, 36) (36, 49, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_109_0000.nii.gz\n",
      "(38, 50, 39) (38, 50, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_114_0000.nii.gz\n",
      "(32, 53, 38) (32, 53, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_123_0000.nii.gz\n",
      "(35, 55, 41) (35, 55, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_124_0000.nii.gz\n",
      "(43, 42, 39) (43, 42, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_125_0000.nii.gz\n",
      "(39, 44, 43) (39, 44, 43) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_126_0000.nii.gz\n",
      "(38, 55, 31) (38, 55, 31) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_127_0000.nii.gz\n",
      "(35, 49, 40) (35, 49, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_130_0000.nii.gz\n",
      "(36, 50, 40) (36, 50, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_132_0000.nii.gz\n",
      "(39, 41, 42) (39, 41, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_133_0000.nii.gz\n",
      "(32, 49, 38) (32, 49, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_135_0000.nii.gz\n",
      "(34, 49, 41) (34, 49, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_136_0000.nii.gz\n",
      "(32, 46, 42) (32, 46, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_138_0000.nii.gz\n",
      "(33, 44, 42) (33, 44, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_141_0000.nii.gz\n",
      "(38, 43, 41) (38, 43, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_142_0000.nii.gz\n",
      "(32, 45, 41) (32, 45, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_143_0000.nii.gz\n",
      "(34, 45, 43) (34, 45, 43) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_144_0000.nii.gz\n",
      "(36, 53, 33) (36, 53, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_145_0000.nii.gz\n",
      "(36, 51, 32) (36, 51, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_146_0000.nii.gz\n",
      "(34, 48, 32) (34, 48, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_148_0000.nii.gz\n",
      "(33, 49, 32) (33, 49, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_149_0000.nii.gz\n",
      "(37, 49, 34) (37, 49, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_150_0000.nii.gz\n",
      "(36, 53, 37) (36, 53, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_152_0000.nii.gz\n",
      "(35, 46, 42) (35, 46, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_154_0000.nii.gz\n",
      "(34, 53, 37) (34, 53, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_155_0000.nii.gz\n",
      "(36, 52, 36) (36, 52, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_156_0000.nii.gz\n",
      "(36, 51, 35) (36, 51, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_157_0000.nii.gz\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(38, 52, 36) (38, 52, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_158_0000.nii.gz\n",
      "(34, 51, 26) (34, 51, 26) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_160_0000.nii.gz\n",
      "(35, 51, 36) (35, 51, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_161_0000.nii.gz\n",
      "(38, 51, 37) (38, 51, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_162_0000.nii.gz\n",
      "(36, 47, 44) (36, 47, 44) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_163_0000.nii.gz\n",
      "(41, 48, 47) (41, 48, 47) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_164_0000.nii.gz\n",
      "(34, 49, 29) (34, 49, 29) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_165_0000.nii.gz\n",
      "(36, 49, 31) (36, 49, 31) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_166_0000.nii.gz\n",
      "(36, 45, 39) (36, 45, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_169_0000.nii.gz\n",
      "(34, 48, 40) (34, 48, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_170_0000.nii.gz\n",
      "(35, 56, 28) (35, 56, 28) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_171_0000.nii.gz\n",
      "(34, 56, 31) (34, 56, 31) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_172_0000.nii.gz\n",
      "(35, 53, 32) (35, 53, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_173_0000.nii.gz\n",
      "(37, 55, 34) (37, 55, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_174_0000.nii.gz\n",
      "(33, 47, 35) (33, 47, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_175_0000.nii.gz\n",
      "(35, 50, 36) (35, 50, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_176_0000.nii.gz\n",
      "(33, 44, 40) (33, 44, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_177_0000.nii.gz\n",
      "(35, 44, 41) (35, 44, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_178_0000.nii.gz\n",
      "(37, 45, 36) (37, 45, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_180_0000.nii.gz\n",
      "(33, 49, 40) (33, 49, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_181_0000.nii.gz\n",
      "(37, 51, 33) (37, 51, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_184_0000.nii.gz\n",
      "(35, 49, 33) (35, 49, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_185_0000.nii.gz\n",
      "(37, 54, 36) (37, 54, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_188_0000.nii.gz\n",
      "(35, 53, 30) (35, 53, 30) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_189_0000.nii.gz\n",
      "(37, 52, 30) (37, 52, 30) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_190_0000.nii.gz\n",
      "(33, 50, 29) (33, 50, 29) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_193_0000.nii.gz\n",
      "(35, 50, 30) (35, 50, 30) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_194_0000.nii.gz\n",
      "(33, 53, 28) (33, 53, 28) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_195_0000.nii.gz\n",
      "(38, 51, 31) (38, 51, 31) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_197_0000.nii.gz\n",
      "(37, 52, 26) (37, 52, 26) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_199_0000.nii.gz\n",
      "(34, 49, 38) (34, 49, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_203_0000.nii.gz\n",
      "(36, 48, 39) (36, 48, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_204_0000.nii.gz\n",
      "(32, 47, 32) (32, 47, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_205_0000.nii.gz\n",
      "(35, 53, 33) (35, 53, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_207_0000.nii.gz\n",
      "(34, 48, 40) (34, 48, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_210_0000.nii.gz\n",
      "(35, 56, 34) (35, 56, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_212_0000.nii.gz\n",
      "(35, 49, 33) (35, 49, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_215_0000.nii.gz\n",
      "(32, 49, 36) (32, 49, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_216_0000.nii.gz\n",
      "(38, 53, 27) (38, 53, 27) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_217_0000.nii.gz\n",
      "(37, 45, 39) (37, 45, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_219_0000.nii.gz\n",
      "(39, 45, 40) (39, 45, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_220_0000.nii.gz\n",
      "(32, 48, 34) (32, 48, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_221_0000.nii.gz\n",
      "(34, 49, 36) (34, 49, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_222_0000.nii.gz\n",
      "(35, 52, 37) (35, 52, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_223_0000.nii.gz\n",
      "(37, 48, 37) (37, 48, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_224_0000.nii.gz\n",
      "(33, 53, 26) (33, 53, 26) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_225_0000.nii.gz\n",
      "(32, 51, 28) (32, 51, 28) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_226_0000.nii.gz\n",
      "(36, 47, 36) (36, 47, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_227_0000.nii.gz\n",
      "(37, 48, 36) (37, 48, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_228_0000.nii.gz\n",
      "(33, 50, 35) (33, 50, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_229_0000.nii.gz\n",
      "(34, 49, 37) (34, 49, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_230_0000.nii.gz\n",
      "(33, 47, 42) (33, 47, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_231_0000.nii.gz\n",
      "(36, 44, 43) (36, 44, 43) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_232_0000.nii.gz\n",
      "(33, 51, 37) (33, 51, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_233_0000.nii.gz\n",
      "(38, 49, 36) (38, 49, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_234_0000.nii.gz\n",
      "(37, 58, 35) (37, 58, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_235_0000.nii.gz\n",
      "(37, 57, 35) (37, 57, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_236_0000.nii.gz\n",
      "(37, 56, 36) (37, 56, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_238_0000.nii.gz\n",
      "(38, 52, 34) (38, 52, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_242_0000.nii.gz\n",
      "(34, 53, 24) (34, 53, 24) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_243_0000.nii.gz\n",
      "(38, 53, 30) (38, 53, 30) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_244_0000.nii.gz\n",
      "(35, 48, 42) (35, 48, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_245_0000.nii.gz\n",
      "(36, 50, 38) (36, 50, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_248_0000.nii.gz\n",
      "(32, 52, 34) (32, 52, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_249_0000.nii.gz\n",
      "(35, 51, 36) (35, 51, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_250_0000.nii.gz\n",
      "(36, 58, 28) (36, 58, 28) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_251_0000.nii.gz\n",
      "(37, 55, 26) (37, 55, 26) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_252_0000.nii.gz\n",
      "(34, 51, 31) (34, 51, 31) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_253_0000.nii.gz\n",
      "(34, 51, 33) (34, 51, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_257_0000.nii.gz\n",
      "(33, 51, 28) (33, 51, 28) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_259_0000.nii.gz\n",
      "(35, 53, 29) (35, 53, 29) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_260_0000.nii.gz\n",
      "(36, 58, 33) (36, 58, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_261_0000.nii.gz\n",
      "(36, 51, 35) (36, 51, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_263_0000.nii.gz\n",
      "(38, 51, 37) (38, 51, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_264_0000.nii.gz\n",
      "(31, 54, 34) (31, 54, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_265_0000.nii.gz\n",
      "(34, 51, 37) (34, 51, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_268_0000.nii.gz\n",
      "(35, 49, 37) (35, 49, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_269_0000.nii.gz\n",
      "(35, 40, 40) (35, 40, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_274_0000.nii.gz\n",
      "(35, 50, 33) (35, 50, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_276_0000.nii.gz\n",
      "(33, 59, 29) (33, 59, 29) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_277_0000.nii.gz\n",
      "(34, 50, 32) (34, 50, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_279_0000.nii.gz\n",
      "(37, 47, 32) (37, 47, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_280_0000.nii.gz\n",
      "(37, 52, 32) (37, 52, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_282_0000.nii.gz\n",
      "(37, 45, 46) (37, 45, 46) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_286_0000.nii.gz\n",
      "(37, 50, 39) (37, 50, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_287_0000.nii.gz\n",
      "(38, 50, 42) (38, 50, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_288_0000.nii.gz\n",
      "(35, 49, 36) (35, 49, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_289_0000.nii.gz\n",
      "(35, 49, 40) (35, 49, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_290_0000.nii.gz\n",
      "(38, 52, 33) (38, 52, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_292_0000.nii.gz\n",
      "(35, 44, 44) (35, 44, 44) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_294_0000.nii.gz\n",
      "(35, 53, 36) (35, 53, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_295_0000.nii.gz\n",
      "(35, 54, 35) (35, 54, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_296_0000.nii.gz\n",
      "(34, 51, 30) (34, 51, 30) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_297_0000.nii.gz\n",
      "(37, 50, 33) (37, 50, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_298_0000.nii.gz\n",
      "(32, 54, 34) (32, 54, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_299_0000.nii.gz\n",
      "(34, 53, 35) (34, 53, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_300_0000.nii.gz\n",
      "(31, 50, 36) (31, 50, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_301_0000.nii.gz\n",
      "(35, 46, 39) (35, 46, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_302_0000.nii.gz\n",
      "(35, 48, 38) (35, 48, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_303_0000.nii.gz\n",
      "(36, 48, 38) (36, 48, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_304_0000.nii.gz\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(34, 49, 30) (34, 49, 30) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_305_0000.nii.gz\n",
      "(38, 48, 40) (38, 48, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_308_0000.nii.gz\n",
      "(34, 52, 38) (34, 52, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_309_0000.nii.gz\n",
      "(35, 52, 38) (35, 52, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_310_0000.nii.gz\n",
      "(37, 49, 37) (37, 49, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_311_0000.nii.gz\n",
      "(37, 53, 33) (37, 53, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_314_0000.nii.gz\n",
      "(37, 51, 33) (37, 51, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_316_0000.nii.gz\n",
      "(33, 51, 34) (33, 51, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_317_0000.nii.gz\n",
      "(37, 51, 33) (37, 51, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_318_0000.nii.gz\n",
      "(33, 48, 34) (33, 48, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_319_0000.nii.gz\n",
      "(33, 47, 34) (33, 47, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_320_0000.nii.gz\n",
      "(34, 46, 34) (34, 46, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_321_0000.nii.gz\n",
      "(38, 47, 37) (38, 47, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_322_0000.nii.gz\n",
      "(35, 51, 40) (35, 51, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_325_0000.nii.gz\n",
      "(36, 49, 41) (36, 49, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_326_0000.nii.gz\n",
      "(36, 54, 27) (36, 54, 27) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_327_0000.nii.gz\n",
      "(38, 54, 30) (38, 54, 30) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_328_0000.nii.gz\n",
      "(34, 53, 32) (34, 53, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_329_0000.nii.gz\n",
      "(35, 55, 33) (35, 55, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_330_0000.nii.gz\n",
      "(35, 52, 33) (35, 52, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_331_0000.nii.gz\n",
      "(35, 52, 33) (35, 52, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_332_0000.nii.gz\n",
      "(33, 46, 38) (33, 46, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_333_0000.nii.gz\n",
      "(34, 47, 36) (34, 47, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_334_0000.nii.gz\n",
      "(32, 47, 41) (32, 47, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_335_0000.nii.gz\n",
      "(34, 47, 43) (34, 47, 43) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_336_0000.nii.gz\n",
      "(33, 44, 41) (33, 44, 41) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_337_0000.nii.gz\n",
      "(37, 43, 43) (37, 43, 43) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_338_0000.nii.gz\n",
      "(35, 46, 38) (35, 46, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_340_0000.nii.gz\n",
      "(34, 48, 35) (34, 48, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_341_0000.nii.gz\n",
      "(32, 45, 38) (32, 45, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_343_0000.nii.gz\n",
      "(32, 49, 30) (32, 49, 30) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_345_0000.nii.gz\n",
      "(34, 50, 34) (34, 50, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_349_0000.nii.gz\n",
      "(35, 49, 34) (35, 49, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_350_0000.nii.gz\n",
      "(35, 51, 35) (35, 51, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_351_0000.nii.gz\n",
      "(38, 51, 35) (38, 51, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_352_0000.nii.gz\n",
      "(32, 51, 31) (32, 51, 31) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_353_0000.nii.gz\n",
      "(36, 50, 32) (36, 50, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_354_0000.nii.gz\n",
      "(33, 47, 38) (33, 47, 38) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_355_0000.nii.gz\n",
      "(36, 51, 37) (36, 51, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_356_0000.nii.gz\n",
      "(35, 50, 34) (35, 50, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_358_0000.nii.gz\n",
      "(35, 49, 35) (35, 49, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_359_0000.nii.gz\n",
      "(34, 49, 37) (34, 49, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_360_0000.nii.gz\n",
      "(36, 50, 33) (36, 50, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_361_0000.nii.gz\n",
      "(38, 52, 35) (38, 52, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_363_0000.nii.gz\n",
      "(37, 47, 34) (37, 47, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_366_0000.nii.gz\n",
      "(36, 57, 37) (36, 57, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_367_0000.nii.gz\n",
      "(38, 55, 40) (38, 55, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_368_0000.nii.gz\n",
      "(35, 50, 36) (35, 50, 36) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_370_0000.nii.gz\n",
      "(36, 50, 34) (36, 50, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_372_0000.nii.gz\n",
      "(34, 49, 35) (34, 49, 35) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_373_0000.nii.gz\n",
      "(38, 48, 39) (38, 48, 39) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_374_0000.nii.gz\n",
      "(32, 54, 34) (32, 54, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_375_0000.nii.gz\n",
      "(35, 55, 37) (35, 55, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_376_0000.nii.gz\n",
      "(35, 52, 34) (35, 52, 34) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_378_0000.nii.gz\n",
      "(35, 46, 42) (35, 46, 42) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_380_0000.nii.gz\n",
      "(33, 49, 37) (33, 49, 37) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_381_0000.nii.gz\n",
      "(33, 55, 29) (33, 55, 29) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_383_0000.nii.gz\n",
      "(35, 48, 40) (35, 48, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_385_0000.nii.gz\n",
      "(37, 45, 40) (37, 45, 40) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_386_0000.nii.gz\n",
      "(33, 51, 32) (33, 51, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_387_0000.nii.gz\n",
      "(34, 49, 32) (34, 49, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_389_0000.nii.gz\n",
      "(38, 51, 33) (38, 51, 33) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_390_0000.nii.gz\n",
      "(36, 51, 31) (36, 51, 31) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_393_0000.nii.gz\n",
      "(36, 52, 32) (36, 52, 32) [0. 1. 2.] /mnt/datawow/lyl/models/nnUNet-master/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task004_Hippocampus/imagesTr/hippocampus_394_0000.nii.gz\n"
     ]
    }
   ],
   "source": [
    "import nibabel as nib\n",
    "import numpy as np\n",
    "\n",
    "def get_shape(name):\n",
    "    img = nib.load(name).get_fdata()\n",
    "    label = nib.load(name.replace('_0000','').replace('imagesTr','labelsTr')).get_fdata()\n",
    "    print(img.shape, label.shape, np.unique(label), name)\n",
    "    return 0\n",
    "\n",
    "for name in train_images:\n",
    "    get_shape(name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Q1Wi6EtAwCMO"
   },
   "source": [
    "## Set deterministic training for reproducibility"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "id": "dr8HRsffwCMO"
   },
   "outputs": [],
   "source": [
    "set_determinism(seed=1645)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "13ZnlKGCwCMO"
   },
   "source": [
    "## Setup transforms for training and validation\n",
    "\n",
    "Here we use several transforms to augment the dataset:\n",
    "1. `LoadImaged` loads the spleen CT images and labels from NIfTI format files.\n",
    "1. `EnsureChannelFirstd` ensures the original data to construct \"channel first\" shape.\n",
    "1. `Spacingd` adjusts the spacing by `pixdim=(1.5, 1.5, 2.)` based on the affine matrix.\n",
    "1. `Orientationd` unifies the data orientation based on the affine matrix.\n",
    "1. `ScaleIntensityRanged` extracts intensity range [-57, 164] and scales to [0, 1].\n",
    "1. `CropForegroundd` removes all zero borders to focus on the valid body area of the images and labels.\n",
    "1. `RandCropByPosNegLabeld` randomly crop patch samples from big image based on pos / neg ratio.  \n",
    "The image centers of negative samples must be in valid body area.\n",
    "1. `RandAffined` efficiently performs `rotate`, `scale`, `shear`, `translate`, etc. together based on PyTorch affine transform.\n",
    "1. `EnsureTyped` converts the numpy array to PyTorch Tensor for further steps."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "id": "jf7siKPOwCMO"
   },
   "outputs": [],
   "source": [
    "roi_size = (32,32,32)\n",
    "train_transforms = Compose(\n",
    "    [\n",
    "        LoadImaged(keys=[\"image\", \"label\"]),\n",
    "        EnsureChannelFirstd(keys=[\"image\", \"label\"]),\n",
    "        ScaleIntensityRanged(\n",
    "            keys=[\"image\"],\n",
    "            a_min=-150,\n",
    "            a_max=250,\n",
    "            b_min=0.0,\n",
    "            b_max=1.0,\n",
    "            clip=True,\n",
    "        ),\n",
    "        CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
    "        Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
    "        Spacingd(keys=[\"image\", \"label\"], pixdim=(1.5, 1.5, 2.0), mode=(\"bilinear\", \"nearest\")),\n",
    "        SpatialPadd(keys=[\"image\", \"label\"], spatial_size=(32, 32, 32), mode=\"constant\"),\n",
    "        RandCropByPosNegLabeld(\n",
    "            keys=[\"image\", \"label\"],\n",
    "            label_key=\"label\",\n",
    "            spatial_size=roi_size,\n",
    "            pos=1,\n",
    "            neg=1,\n",
    "            num_samples=4,\n",
    "            image_key=\"image\",\n",
    "            image_threshold=0,\n",
    "        ),\n",
    "        \n",
    "        # user can also add other random transforms\n",
    "        # RandAffined(\n",
    "        #     keys=['image', 'label'],\n",
    "        #     mode=('bilinear', 'nearest'),\n",
    "        #     prob=1.0, spatial_size=(96, 96, 96),\n",
    "        #     rotate_range=(0, 0, np.pi/15),\n",
    "        #     scale_range=(0.1, 0.1, 0.1)),\n",
    "    ]\n",
    ")\n",
    "val_transforms = Compose(\n",
    "    [\n",
    "        LoadImaged(keys=[\"image\", \"label\"]),\n",
    "        EnsureChannelFirstd(keys=[\"image\", \"label\"]),\n",
    "        ScaleIntensityRanged(\n",
    "            keys=[\"image\"],\n",
    "            a_min=-150,\n",
    "            a_max=250,\n",
    "            b_min=0.0,\n",
    "            b_max=1.0,\n",
    "            clip=True,\n",
    "        ),\n",
    "        CropForegroundd(keys=[\"image\", \"label\"], source_key=\"image\"),\n",
    "        Orientationd(keys=[\"image\", \"label\"], axcodes=\"RAS\"),\n",
    "        Spacingd(keys=[\"image\", \"label\"], pixdim=(1.5, 1.5, 2.0), mode=(\"bilinear\", \"nearest\")),\n",
    "                SpatialPadd(keys=[\"image\", \"label\"], spatial_size=(32, 32, 32), mode=\"constant\"),\n",
    "\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "au4rmQfDwCMP"
   },
   "source": [
    "## Check transforms in DataLoader"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 408
    },
    "id": "qqcFPuVkwCMP",
    "outputId": "4189428e-4569-4453-e379-df4466208c85",
    "tags": []
   },
   "outputs": [],
   "source": [
    "# check_ds = Dataset(data=val_files, transform=val_transforms)\n",
    "# check_loader = DataLoader(check_ds, batch_size=1)\n",
    "# check_data = first(check_loader)\n",
    "# image, label = (check_data[\"image\"][0][0], check_data[\"label\"][0][0])\n",
    "# print(f\"image shape: {image.shape}, label shape: {label.shape}\")\n",
    "# # plot the slice [:, :, 80]\n",
    "\n",
    "# plt.figure(\"check\", (12, 6))\n",
    "# plt.subplot(1, 2, 1)\n",
    "# plt.title(\"image\")\n",
    "# plt.imshow(image[:, :, 30], cmap=\"gray\")\n",
    "# plt.subplot(1, 2, 2)\n",
    "# plt.title(\"label\")\n",
    "# plt.imshow(label[:, :, 30])\n",
    "# plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "D0_EHJ7FwCMQ"
   },
   "source": [
    "## Define CacheDataset and DataLoader for training and validation\n",
    "\n",
    "Here we use CacheDataset to accelerate training and validation process, it's 10x faster than the regular Dataset.  \n",
    "To achieve best performance, set `cache_rate=1.0` to cache all the data, if memory is not enough, set lower value.  \n",
    "Users can also set `cache_num` instead of `cache_rate`, will use the minimum value of the 2 settings.  \n",
    "And set `num_workers` to enable multi-threads during caching.  \n",
    "If want to to try the regular Dataset, just change to use the commented code below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "kKA4gboPwCMQ",
    "outputId": "2496df99-8445-4c70-a3b1-721f9e552b34",
    "tags": []
   },
   "outputs": [],
   "source": [
    "# train_ds = CacheDataset(data=train_files, transform=train_transforms, cache_rate=1.0, num_workers=4)\n",
    "train_ds = Dataset(data=train_files, transform=train_transforms)\n",
    "\n",
    "# use batch_size=2 to load images and use RandCropByPosNegLabeld\n",
    "# to generate 2 x 4 images for network training\n",
    "train_loader = DataLoader(train_ds, batch_size=2, shuffle=True, num_workers=4)\n",
    "\n",
    "# val_ds = CacheDataset(data=val_files, transform=val_transforms, cache_rate=1.0, num_workers=4)\n",
    "val_ds = Dataset(data=val_files, transform=val_transforms)\n",
    "val_loader = DataLoader(val_ds, batch_size=1, num_workers=4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([8, 1, 32, 32, 32]) torch.Size([8, 1, 32, 32, 32])\n",
      "torch.Size([8, 1, 32, 32, 32]) torch.Size([8, 1, 32, 32, 32])\n",
      "torch.Size([8, 1, 32, 32, 32]) torch.Size([8, 1, 32, 32, 32])\n",
      "torch.Size([8, 1, 32, 32, 32]) torch.Size([8, 1, 32, 32, 32])\n",
      "torch.Size([8, 1, 32, 32, 32]) torch.Size([8, 1, 32, 32, 32])\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "\n",
    "step=0\n",
    "for batch_data in train_loader:\n",
    "    step+=1\n",
    "    inputs, labels = (\n",
    "        batch_data[\"image\"].to(device),\n",
    "        batch_data[\"label\"].to(device),\n",
    "    )\n",
    "    print(inputs.shape, labels.shape)\n",
    "    if step==5:\n",
    "        break\n",
    "\n",
    "import numpy as np\n",
    "num_classes = len(np.unique(labels))\n",
    "print(num_classes)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "nOgy1x1BwCMQ"
   },
   "source": [
    "## Create Model, Loss, Optimizer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset_name = 'Task004_Hippocampus'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "id": "VM-5g2bmwCMQ"
   },
   "outputs": [],
   "source": [
    "# standard PyTorch program style: create UNet, DiceLoss and Adam optimizer\n",
    "device = torch.device(\"cuda:0\")\n",
    "\n",
    "UNet_meatdata = {\n",
    "    \"spatial_dims\": 3,\n",
    "    \"in_channels\": 1,\n",
    "    \"out_channels\": num_classes,\n",
    "     \"strides\": (2, 2, 2),\n",
    "    \"num_res_units\": 2,\n",
    "    \"channels\":(4, 8, 16, 32),\n",
    "    \"norm\": Norm.BATCH,\n",
    "}\n",
    "\n",
    "model = UNet(**UNet_meatdata).to(device)\n",
    "loss_function = DiceLoss(to_onehot_y=True, softmax=True)\n",
    "loss_type = \"DiceLoss\"\n",
    "optimizer = torch.optim.Adam(model.parameters(), 1e-4)\n",
    "dice_metric = DiceMetric(include_background=False, reduction=\"mean\")\n",
    "\n",
    "Optimizer_metadata = {}\n",
    "for ind, param_group in enumerate(optimizer.param_groups):\n",
    "    optim_meta_keys = list(param_group.keys())\n",
    "    Optimizer_metadata[f\"param_group_{ind}\"] = {\n",
    "        key: value for (key, value) in param_group.items() if \"params\" not in key\n",
    "    }\n",
    "aim_run = aim.Run()\n",
    "aim_run.name = f'{dataset_name}_{model.__class__.__name__}'\n",
    "# log model metadata\n",
    "aim_run[f\"{model.__class__.__name__}_meatdata\"] = UNet_meatdata\n",
    "# log optimizer metadata\n",
    "aim_run[\"Optimizer_metadata\"] = Optimizer_metadata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "VM-5g2bmwCMQ"
   },
   "outputs": [],
   "source": [
    "# standard PyTorch program style: create UNet, DiceLoss and Adam optimizer\n",
    "device = torch.device(\"cuda:0\")\n",
    "\n",
    "net_metadata = {\n",
    "    \"spatial_dims\": 3,\n",
    "    \"in_channels\": 4,\n",
    "    \"out_channels\": num_classes,\n",
    "    \"img_size\": (96, 96, 32),\n",
    "    \"mlp_dim\": 3072\n",
    "    #  \"strides\": (2, 2, 2, 2),\n",
    "    # \"num_res_units\": 2,\n",
    "    # \"channels\":(4, 8, 16, 32, 64),\n",
    "    # \"norm\": Norm.BATCH,\n",
    "}\n",
    "\n",
    "model = UNETR(**net_metadata).to(device)\n",
    "loss_function = DiceLoss(to_onehot_y=True, softmax=True)\n",
    "loss_type = \"DiceLoss\"\n",
    "optimizer = torch.optim.Adam(model.parameters(), 1e-4)\n",
    "dice_metric = DiceMetric(include_background=False, reduction=\"mean\")\n",
    "\n",
    "Optimizer_metadata = {}\n",
    "for ind, param_group in enumerate(optimizer.param_groups):\n",
    "    optim_meta_keys = list(param_group.keys())\n",
    "    Optimizer_metadata[f\"param_group_{ind}\"] = {\n",
    "        key: value for (key, value) in param_group.items() if \"params\" not in key\n",
    "    }\n",
    "aim_run = aim.Run()\n",
    "aim_run.name = f'{dataset_name}_{model.__class__.__name__}'\n",
    "# log model metadata\n",
    "aim_run[f\"{model.__class__.__name__}_meatdata\"] = net_metadata\n",
    "# log optimizer metadata\n",
    "aim_run[\"Optimizer_metadata\"] = Optimizer_metadata\n",
    "print(aim_run.name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "4nD1pAY-wCMR"
   },
   "source": [
    "## Execute a typical PyTorch training process"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "id": "KayxFseYwCMR",
    "scrolled": false,
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "----------\n",
      "epoch 1/600\n",
      "1/39, train_loss: 0.7064\n",
      "2/39, train_loss: 0.7048\n",
      "3/39, train_loss: 0.6997\n",
      "4/39, train_loss: 0.6991\n",
      "5/39, train_loss: 0.6916\n",
      "6/39, train_loss: 0.6946\n",
      "7/39, train_loss: 0.6980\n",
      "8/39, train_loss: 0.7045\n",
      "9/39, train_loss: 0.6995\n",
      "10/39, train_loss: 0.6970\n",
      "11/39, train_loss: 0.7000\n",
      "12/39, train_loss: 0.7019\n",
      "13/39, train_loss: 0.6933\n",
      "14/39, train_loss: 0.6904\n",
      "15/39, train_loss: 0.6978\n",
      "16/39, train_loss: 0.6889\n",
      "17/39, train_loss: 0.6868\n",
      "18/39, train_loss: 0.6954\n",
      "19/39, train_loss: 0.6920\n",
      "20/39, train_loss: 0.6893\n",
      "21/39, train_loss: 0.6897\n",
      "22/39, train_loss: 0.6950\n",
      "23/39, train_loss: 0.6851\n",
      "24/39, train_loss: 0.6958\n",
      "25/39, train_loss: 0.6855\n",
      "26/39, train_loss: 0.6957\n",
      "27/39, train_loss: 0.6943\n",
      "28/39, train_loss: 0.6908\n",
      "29/39, train_loss: 0.6913\n",
      "30/39, train_loss: 0.6909\n",
      "31/39, train_loss: 0.6924\n",
      "32/39, train_loss: 0.6922\n",
      "33/39, train_loss: 0.6868\n",
      "34/39, train_loss: 0.6846\n",
      "35/39, train_loss: 0.6789\n",
      "36/39, train_loss: 0.6887\n",
      "37/39, train_loss: 0.6873\n",
      "38/39, train_loss: 0.6887\n",
      "39/39, train_loss: 0.6907\n",
      "epoch 1 average loss: 0.6932\n",
      "----------\n",
      "epoch 2/600\n",
      "1/39, train_loss: 0.6823\n",
      "2/39, train_loss: 0.6790\n",
      "3/39, train_loss: 0.6852\n",
      "4/39, train_loss: 0.6830\n",
      "5/39, train_loss: 0.6845\n",
      "6/39, train_loss: 0.6834\n",
      "7/39, train_loss: 0.6854\n",
      "8/39, train_loss: 0.6750\n",
      "9/39, train_loss: 0.6830\n",
      "10/39, train_loss: 0.6810\n",
      "11/39, train_loss: 0.6752\n",
      "12/39, train_loss: 0.6754\n",
      "13/39, train_loss: 0.6804\n",
      "14/39, train_loss: 0.6799\n",
      "15/39, train_loss: 0.6748\n",
      "16/39, train_loss: 0.6737\n",
      "17/39, train_loss: 0.6860\n",
      "18/39, train_loss: 0.6837\n",
      "19/39, train_loss: 0.6847\n",
      "20/39, train_loss: 0.6733\n",
      "21/39, train_loss: 0.6852\n",
      "22/39, train_loss: 0.6764\n",
      "23/39, train_loss: 0.6806\n",
      "24/39, train_loss: 0.6726\n",
      "25/39, train_loss: 0.6828\n",
      "26/39, train_loss: 0.6719\n",
      "27/39, train_loss: 0.6762\n",
      "28/39, train_loss: 0.6687\n",
      "29/39, train_loss: 0.6710\n",
      "30/39, train_loss: 0.6705\n",
      "31/39, train_loss: 0.6699\n",
      "32/39, train_loss: 0.6734\n",
      "33/39, train_loss: 0.6656\n",
      "34/39, train_loss: 0.6740\n",
      "35/39, train_loss: 0.6713\n",
      "36/39, train_loss: 0.6639\n",
      "37/39, train_loss: 0.6661\n",
      "38/39, train_loss: 0.6780\n",
      "39/39, train_loss: 0.6648\n",
      "epoch 2 average loss: 0.6767\n",
      "----------\n",
      "epoch 3/600\n",
      "1/39, train_loss: 0.6771\n",
      "2/39, train_loss: 0.6571\n",
      "3/39, train_loss: 0.6680\n",
      "4/39, train_loss: 0.6583\n",
      "5/39, train_loss: 0.6667\n",
      "6/39, train_loss: 0.6669\n",
      "7/39, train_loss: 0.6626\n",
      "8/39, train_loss: 0.6627\n",
      "9/39, train_loss: 0.6596\n",
      "10/39, train_loss: 0.6670\n",
      "11/39, train_loss: 0.6575\n",
      "12/39, train_loss: 0.6627\n",
      "13/39, train_loss: 0.6600\n",
      "14/39, train_loss: 0.6636\n",
      "15/39, train_loss: 0.6637\n",
      "16/39, train_loss: 0.6590\n",
      "17/39, train_loss: 0.6622\n",
      "18/39, train_loss: 0.6577\n",
      "19/39, train_loss: 0.6606\n",
      "20/39, train_loss: 0.6534\n",
      "21/39, train_loss: 0.6670\n",
      "22/39, train_loss: 0.6611\n",
      "23/39, train_loss: 0.6563\n",
      "24/39, train_loss: 0.6532\n",
      "25/39, train_loss: 0.6717\n",
      "26/39, train_loss: 0.6640\n",
      "27/39, train_loss: 0.6574\n",
      "28/39, train_loss: 0.6546\n",
      "29/39, train_loss: 0.6633\n",
      "30/39, train_loss: 0.6521\n",
      "31/39, train_loss: 0.6480\n",
      "32/39, train_loss: 0.6560\n",
      "33/39, train_loss: 0.6706\n",
      "34/39, train_loss: 0.6555\n",
      "35/39, train_loss: 0.6550\n",
      "36/39, train_loss: 0.6557\n",
      "37/39, train_loss: 0.6612\n",
      "38/39, train_loss: 0.6562\n",
      "39/39, train_loss: 0.6516\n",
      "epoch 3 average loss: 0.6604\n",
      "----------\n",
      "epoch 4/600\n",
      "1/39, train_loss: 0.6543\n",
      "2/39, train_loss: 0.6596\n",
      "3/39, train_loss: 0.6480\n",
      "4/39, train_loss: 0.6447\n",
      "5/39, train_loss: 0.6486\n",
      "6/39, train_loss: 0.6572\n",
      "7/39, train_loss: 0.6479\n",
      "8/39, train_loss: 0.6486\n",
      "9/39, train_loss: 0.6631\n",
      "10/39, train_loss: 0.6440\n",
      "11/39, train_loss: 0.6476\n",
      "12/39, train_loss: 0.6579\n",
      "13/39, train_loss: 0.6429\n",
      "14/39, train_loss: 0.6433\n",
      "15/39, train_loss: 0.6523\n",
      "16/39, train_loss: 0.6402\n",
      "17/39, train_loss: 0.6520\n",
      "18/39, train_loss: 0.6434\n",
      "19/39, train_loss: 0.6341\n",
      "20/39, train_loss: 0.6474\n",
      "21/39, train_loss: 0.6468\n",
      "22/39, train_loss: 0.6436\n",
      "23/39, train_loss: 0.6443\n",
      "24/39, train_loss: 0.6461\n",
      "25/39, train_loss: 0.6330\n",
      "26/39, train_loss: 0.6442\n",
      "27/39, train_loss: 0.6375\n",
      "28/39, train_loss: 0.6406\n",
      "29/39, train_loss: 0.6312\n",
      "30/39, train_loss: 0.6454\n",
      "31/39, train_loss: 0.6368\n",
      "32/39, train_loss: 0.6371\n",
      "33/39, train_loss: 0.6454\n",
      "34/39, train_loss: 0.6399\n",
      "35/39, train_loss: 0.6398\n",
      "36/39, train_loss: 0.6304\n",
      "37/39, train_loss: 0.6330\n",
      "38/39, train_loss: 0.6361\n",
      "39/39, train_loss: 0.6245\n",
      "epoch 4 average loss: 0.6439\n",
      "----------\n",
      "epoch 5/600\n",
      "1/39, train_loss: 0.6324\n",
      "2/39, train_loss: 0.6425\n",
      "3/39, train_loss: 0.6299\n",
      "4/39, train_loss: 0.6311\n",
      "5/39, train_loss: 0.6340\n",
      "6/39, train_loss: 0.6304\n",
      "7/39, train_loss: 0.6328\n",
      "8/39, train_loss: 0.6320\n",
      "9/39, train_loss: 0.6287\n",
      "10/39, train_loss: 0.6286\n",
      "11/39, train_loss: 0.6407\n",
      "12/39, train_loss: 0.6331\n",
      "13/39, train_loss: 0.6422\n",
      "14/39, train_loss: 0.6249\n",
      "15/39, train_loss: 0.6262\n",
      "16/39, train_loss: 0.6272\n",
      "17/39, train_loss: 0.6379\n",
      "18/39, train_loss: 0.6370\n",
      "19/39, train_loss: 0.6289\n",
      "20/39, train_loss: 0.6233\n",
      "21/39, train_loss: 0.6238\n",
      "22/39, train_loss: 0.6141\n",
      "23/39, train_loss: 0.6228\n",
      "24/39, train_loss: 0.6253\n",
      "25/39, train_loss: 0.6168\n",
      "26/39, train_loss: 0.6327\n",
      "27/39, train_loss: 0.6187\n",
      "28/39, train_loss: 0.6397\n",
      "29/39, train_loss: 0.6388\n",
      "30/39, train_loss: 0.6242\n",
      "31/39, train_loss: 0.6315\n",
      "32/39, train_loss: 0.6162\n",
      "33/39, train_loss: 0.6154\n",
      "34/39, train_loss: 0.6288\n",
      "35/39, train_loss: 0.6179\n",
      "36/39, train_loss: 0.6169\n",
      "37/39, train_loss: 0.6108\n",
      "38/39, train_loss: 0.6196\n",
      "39/39, train_loss: 0.6229\n",
      "epoch 5 average loss: 0.6277\n"
     ]
    },
    {
     "ename": "IndexError",
     "evalue": "index 15 is out of bounds for dimension 3 with size 14",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[37], line 63\u001b[0m\n\u001b[1;32m     60\u001b[0m val_outputs \u001b[38;5;241m=\u001b[39m sliding_window_inference(val_inputs, roi_size, sw_batch_size, model)\n\u001b[1;32m     62\u001b[0m \u001b[38;5;66;03m# tracking input, label and output images with Aim\u001b[39;00m\n\u001b[0;32m---> 63\u001b[0m output \u001b[38;5;241m=\u001b[39m \u001b[43mtorch\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43margmax\u001b[49m\u001b[43m(\u001b[49m\u001b[43mval_outputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdim\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m:\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m:\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mslice_to_track\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241m.\u001b[39mfloat()\n\u001b[1;32m     65\u001b[0m aim_run\u001b[38;5;241m.\u001b[39mtrack(\n\u001b[1;32m     66\u001b[0m     aim\u001b[38;5;241m.\u001b[39mImage(val_inputs[\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m0\u001b[39m, :, :, slice_to_track], caption\u001b[38;5;241m=\u001b[39m\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInput Image: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mindex\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m),\n\u001b[1;32m     67\u001b[0m     name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvalidation\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m     68\u001b[0m     context\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtype\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124minput\u001b[39m\u001b[38;5;124m\"\u001b[39m},\n\u001b[1;32m     69\u001b[0m )\n\u001b[1;32m     70\u001b[0m aim_run\u001b[38;5;241m.\u001b[39mtrack(\n\u001b[1;32m     71\u001b[0m     aim\u001b[38;5;241m.\u001b[39mImage(val_labels[\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m0\u001b[39m, :, :, slice_to_track], caption\u001b[38;5;241m=\u001b[39m\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mLabel Image: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mindex\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m),\n\u001b[1;32m     72\u001b[0m     name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mvalidation\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m     73\u001b[0m     context\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtype\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mlabel\u001b[39m\u001b[38;5;124m\"\u001b[39m},\n\u001b[1;32m     74\u001b[0m )\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.10/site-packages/monai/data/meta_tensor.py:276\u001b[0m, in \u001b[0;36mMetaTensor.__torch_function__\u001b[0;34m(cls, func, types, args, kwargs)\u001b[0m\n\u001b[1;32m    274\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m kwargs \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m    275\u001b[0m     kwargs \u001b[38;5;241m=\u001b[39m {}\n\u001b[0;32m--> 276\u001b[0m ret \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m__torch_function__\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtypes\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    277\u001b[0m \u001b[38;5;66;03m# if `out` has been used as argument, metadata is not copied, nothing to do.\u001b[39;00m\n\u001b[1;32m    278\u001b[0m \u001b[38;5;66;03m# if \"out\" in kwargs:\u001b[39;00m\n\u001b[1;32m    279\u001b[0m \u001b[38;5;66;03m#     return ret\u001b[39;00m\n\u001b[1;32m    280\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m _not_requiring_metadata(ret):\n",
      "File \u001b[0;32m~/anaconda3/lib/python3.10/site-packages/torch/_tensor.py:1295\u001b[0m, in \u001b[0;36mTensor.__torch_function__\u001b[0;34m(cls, func, types, args, kwargs)\u001b[0m\n\u001b[1;32m   1292\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mNotImplemented\u001b[39m\n\u001b[1;32m   1294\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m _C\u001b[38;5;241m.\u001b[39mDisableTorchFunctionSubclass():\n\u001b[0;32m-> 1295\u001b[0m     ret \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   1296\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m func \u001b[38;5;129;01min\u001b[39;00m get_default_nowrap_functions():\n\u001b[1;32m   1297\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m ret\n",
      "\u001b[0;31mIndexError\u001b[0m: index 15 is out of bounds for dimension 3 with size 14"
     ]
    }
   ],
   "source": [
    "max_epochs = 600\n",
    "val_interval = 5\n",
    "best_metric = -1\n",
    "best_metric_epoch = -1\n",
    "epoch_loss_values = []\n",
    "metric_values = []\n",
    "post_pred = Compose([AsDiscrete(argmax=True, to_onehot=num_classes)])\n",
    "post_label = Compose([AsDiscrete(to_onehot=num_classes)])\n",
    "\n",
    "slice_to_track = 15\n",
    "\n",
    "for epoch in range(max_epochs):\n",
    "    print(\"-\" * 10)\n",
    "    print(f\"epoch {epoch + 1}/{max_epochs}\")\n",
    "    model.train()\n",
    "    epoch_loss = 0\n",
    "    step = 0\n",
    "    for batch_data in train_loader:\n",
    "        step += 1\n",
    "        inputs, labels = (\n",
    "            batch_data[\"image\"].to(device),\n",
    "            batch_data[\"label\"].to(device),\n",
    "        )\n",
    "        \n",
    "        optimizer.zero_grad()\n",
    "        outputs = model(inputs)\n",
    "        loss = loss_function(outputs, labels)\n",
    "        loss.backward()\n",
    "        optimizer.step()\n",
    "        epoch_loss += loss.item()\n",
    "        print(f\"{step}/{len(train_ds) // train_loader.batch_size}, \" f\"train_loss: {loss.item():.4f}\")\n",
    "        # track batch loss metric\n",
    "        aim_run.track(loss.item(), name=\"batch_loss\", context={\"type\": loss_type})\n",
    "\n",
    "    epoch_loss /= step\n",
    "    epoch_loss_values.append(epoch_loss)\n",
    "\n",
    "    # track epoch loss metric\n",
    "    aim_run.track(epoch_loss, name=\"epoch_loss\", context={\"type\": loss_type})\n",
    "\n",
    "    print(f\"epoch {epoch + 1} average loss: {epoch_loss:.4f}\")\n",
    "\n",
    "    if (epoch + 1) % val_interval == 0:\n",
    "        if (epoch + 1) % val_interval * 2 == 0:\n",
    "            # track model params and gradients\n",
    "            track_params_dists(model, aim_run)\n",
    "            # THIS SEGMENT TAKES RELATIVELY LONG (Advise Against it)\n",
    "            track_gradients_dists(model, aim_run)\n",
    "\n",
    "        model.eval()\n",
    "        with torch.no_grad():\n",
    "            for index, val_data in enumerate(val_loader):\n",
    "                val_inputs, val_labels = (\n",
    "                    val_data[\"image\"].to(device),\n",
    "                    val_data[\"label\"].to(device),\n",
    "                )\n",
    "                # roi_size = (160, 160, 160)\n",
    "\n",
    "                sw_batch_size = 4\n",
    "                val_outputs = sliding_window_inference(val_inputs, roi_size, sw_batch_size, model)\n",
    "\n",
    "                # tracking input, label and output images with Aim\n",
    "                output = torch.argmax(val_outputs, dim=1)[0, :, :, slice_to_track].float()\n",
    "\n",
    "                aim_run.track(\n",
    "                    aim.Image(val_inputs[0, 0, :, :, slice_to_track], caption=f\"Input Image: {index}\"),\n",
    "                    name=\"validation\",\n",
    "                    context={\"type\": \"input\"},\n",
    "                )\n",
    "                aim_run.track(\n",
    "                    aim.Image(val_labels[0, 0, :, :, slice_to_track], caption=f\"Label Image: {index}\"),\n",
    "                    name=\"validation\",\n",
    "                    context={\"type\": \"label\"},\n",
    "                )\n",
    "                aim_run.track(\n",
    "                    aim.Image(output, caption=f\"Predicted Label: {index}\"),\n",
    "                    name=\"predictions\",\n",
    "                    context={\"type\": \"labels\"},\n",
    "                )\n",
    "\n",
    "                val_outputs = [post_pred(i) for i in decollate_batch(val_outputs)]\n",
    "                val_labels = [post_label(i) for i in decollate_batch(val_labels)]\n",
    "                # compute metric for current iteration\n",
    "                dice_metric(y_pred=val_outputs, y=val_labels)\n",
    "\n",
    "            # aggregate the final mean dice result\n",
    "            metric = dice_metric.aggregate().item()\n",
    "            # track val metric\n",
    "            aim_run.track(metric, name=\"val_metric\", context={\"type\": loss_type})\n",
    "\n",
    "            # reset the status for next validation round\n",
    "            dice_metric.reset()\n",
    "\n",
    "            metric_values.append(metric)\n",
    "            if metric > best_metric:\n",
    "                best_metric = metric\n",
    "                best_metric_epoch = epoch + 1\n",
    "                torch.save(model.state_dict(), os.path.join(root_dir, f\"{aim_run.name}_best_metric_model.pth\"))\n",
    "\n",
    "                best_model_log_message = f\"saved new best metric model at the {epoch+1}th epoch\"\n",
    "                aim_run.track(aim.Text(best_model_log_message), name=\"best_model_log_message\", epoch=epoch + 1)\n",
    "                print(best_model_log_message)\n",
    "\n",
    "            message1 = f\"current epoch: {epoch + 1} current mean dice: {metric:.4f}\"\n",
    "            message2 = f\"\\nbest mean dice: {best_metric:.4f} \"\n",
    "            message3 = f\"at epoch: {best_metric_epoch}\"\n",
    "\n",
    "            aim_run.track(aim.Text(message1 + \"\\n\" + message2 + message3), name=\"epoch_summary\", epoch=epoch + 1)\n",
    "            print(message1, message2, message3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "d1WMn7DFKkbV"
   },
   "outputs": [],
   "source": [
    "# finalize Aim Run\n",
    "aim_run.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "ygo9hrWswCMR",
    "tags": []
   },
   "outputs": [],
   "source": [
    "print(f\"train completed, best_metric: {best_metric:.4f} \" f\"at epoch: {best_metric_epoch}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "run = aim.Run('dc7f4adf500345a78a890961')\n",
    "run.name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "run.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "jGhCvBg-wCMS"
   },
   "outputs": [],
   "source": [
    "%load_ext aim\n",
    "%aim up"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "zV7fV0CIwCMS"
   },
   "source": [
    "Once the above cell is executed, you will see the Aim UI running in output cell\n",
    "\n",
    "![Aim UI](https://user-images.githubusercontent.com/13848158/156644374-ba04963f-4f63-4fb9-b3ef-4d4e1ae521cc.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "KRw5pgLiwCMS"
   },
   "source": [
    "## Explore the loss and metric"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "MeX1wBjXwCMS"
   },
   "source": [
    "Compare metrics curves with Metrics Explorer - group and aggregate by any hyperparameter to easily compare training runs\n",
    "\n",
    "![Metrics Explorer](https://user-images.githubusercontent.com/13848158/156642623-8cf4911d-bed2-42b8-9f39-374f8d31def8.jpg)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "zGZ5vozGwCMS"
   },
   "source": [
    "## Compare and analyze model outputs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "mZIUa0aNwCMS"
   },
   "source": [
    "Compare models of different runs with input images and labels\n",
    "\n",
    "![Images Explorer](https://user-images.githubusercontent.com/13848158/156642615-c003fb3c-9f37-40f4-b499-ee6623db59ef.jpg)\n",
    "\n",
    "![Images Explorer](https://user-images.githubusercontent.com/13848158/156642618-0c0c380a-75aa-45b1-b431-149f735b3fde.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "uZKhs2DFwCMS"
   },
   "source": [
    "## Evaluation on original image spacings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "Ws5wpqPlwCMT"
   },
   "outputs": [],
   "source": [
    "val_org_transforms = Compose(\n",
    "    [\n",
    "        LoadImaged(keys=[\"image\", \"label\"]),\n",
    "        EnsureChannelFirstd(keys=[\"image\", \"label\"]),\n",
    "        Spacingd(keys=[\"image\"], pixdim=(1.5, 1.5, 2.0), mode=\"bilinear\"),\n",
    "        Orientationd(keys=[\"image\"], axcodes=\"RAS\"),\n",
    "        ScaleIntensityRanged(\n",
    "            keys=[\"image\"],\n",
    "            a_min=-57,\n",
    "            a_max=164,\n",
    "            b_min=0.0,\n",
    "            b_max=1.0,\n",
    "            clip=True,\n",
    "        ),\n",
    "        CropForegroundd(keys=[\"image\"], source_key=\"image\"),\n",
    "    ]\n",
    ")\n",
    "\n",
    "val_org_ds = Dataset(data=val_files, transform=val_org_transforms)\n",
    "val_org_loader = DataLoader(val_org_ds, batch_size=1, num_workers=4)\n",
    "\n",
    "post_transforms = Compose(\n",
    "    [\n",
    "        Invertd(\n",
    "            keys=\"pred\",\n",
    "            transform=val_org_transforms,\n",
    "            orig_keys=\"image\",\n",
    "            meta_keys=\"pred_meta_dict\",\n",
    "            orig_meta_keys=\"image_meta_dict\",\n",
    "            meta_key_postfix=\"meta_dict\",\n",
    "            nearest_interp=False,\n",
    "            to_tensor=True,\n",
    "        ),\n",
    "        AsDiscreted(keys=\"pred\", argmax=True, to_onehot=2),\n",
    "        AsDiscreted(keys=\"label\", to_onehot=2),\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "JTkKUwRGwCMT"
   },
   "outputs": [],
   "source": [
    "model.load_state_dict(torch.load(os.path.join(root_dir, \"best_metric_model.pth\")))\n",
    "model.eval()\n",
    "\n",
    "with torch.no_grad():\n",
    "    for val_data in val_org_loader:\n",
    "        val_data[\"image\"] = val_data[\"image\"].to(device)\n",
    "        val_data[\"label\"] = val_data[\"label\"].to(device)\n",
    "        roi_size = (160, 160, 160)\n",
    "        sw_batch_size = 4\n",
    "        val_data[\"pred\"] = sliding_window_inference(val_data[\"image\"], roi_size, sw_batch_size, model)\n",
    "        val_data = [post_transforms(i) for i in decollate_batch(val_data)]\n",
    "        val_outputs, val_labels = from_engine([\"pred\", \"label\"])(val_data)\n",
    "        # compute metric for current iteration\n",
    "        dice_metric(y_pred=val_outputs, y=val_labels)\n",
    "\n",
    "    # aggregate the final mean dice result\n",
    "    metric_org = dice_metric.aggregate().item()\n",
    "    # reset the status for next validation round\n",
    "    dice_metric.reset()\n",
    "\n",
    "print(\"Metric on original image spacing: \", metric_org)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "chILRaduwCMT"
   },
   "source": [
    "## Cleanup data directory\n",
    "\n",
    "Remove directory if a temporary was used."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "yuCFCxOcwCMT"
   },
   "outputs": [],
   "source": [
    "if directory is None:\n",
    "    shutil.rmtree(root_dir)"
   ]
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "name": "spleen_segmentation_3d_visualization.ipynb",
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  },
  "vscode": {
   "interpreter": {
    "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
